Searched hist:"50290 c00" (Results 1 – 1 of 1) sorted by relevance
/qemu/ |
H A D | qemu-io-cmds.c | 50290c00 Wed May 29 16:16:32 GMT 2019 Alex Bennée <alex.bennee@linaro.org> qemu-io-cmds: use clock_gettime for benchmarking
The previous use of gettimeofday() ran into undefined behaviour when we ended up doing a div 0 for a very short operation. This is because gettimeofday only works at the microsecond level as well as being prone to discontinuous jumps in system time. Using clock_gettime with CLOCK_MONOTONIC gives greater precision and alleviates some of the potential problems with time jumping around.
We could use CLOCK_MONOTONIC_RAW to avoid being tripped up by NTP and adjtime but that is Linux specific so I decided it would do for now.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
|